﻿using DAL;
using DAL.FKTZ;
using DAL.JSGN;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL.FKTZ
{
    public class FktzAttachmentBLL
    {
        private readonly FktzDataContext _dataContext;
        private readonly FktzAttachmentDAL _attachmentDAL;

        public FktzAttachmentBLL()
        {
            _dataContext = new FktzDataContext();
            _attachmentDAL = new FktzAttachmentDAL(_dataContext);
        }

        public async Task<FktzAttachmentModel> GetAsync(string id)
        {
            var entity = await _attachmentDAL.GetAsync(id);
            if (entity == null) return null;
            return new FktzAttachmentModel() { AttachmentId = entity.AttachmentId, FileName = entity.FileName, Extension = entity.Extension, MediaType = entity.MediaType, FileStream = entity.FileStream };
        }
        public Task<IEnumerable<FktzAttachmentModel>> GetAsync(string id,string type)
        {
            var data =  _attachmentDAL.ListAsync(id).Result;
            var models = data.Select(x => new FktzAttachmentModel()
            { AttachmentId = x.AttachmentId, FileName = x.FileName, Extension = x.Extension, MediaType = x.MediaType });
            return Task.FromResult(models);
        }
        public async Task CreateAsync(FktzAttachmentModel model)
        {
        }
    }
}
